﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using SKDB_Matcher.SQL.DataTypeCompareResults;

namespace SKDB_Matcher.SQL
{
    class CTestClass
    {
        public static void runTests()
        {
            //Test Parsing DataTypes
            CSQLDataType temp = null;
            try
            {
                temp = CSQLDataType.Parse("VarChar(100)");
                temp = CSQLDataType.Parse("  VarChar ( 100  ) ");
                temp = CSQLDataType.Parse("int");
                temp = CSQLDataType.Parse("decimal(8)");
                temp = CSQLDataType.Parse("decimal(8,2)");
                temp = CSQLDataType.Parse("nchar");
                temp = CSQLDataType.Parse("text");
                temp = CSQLDataType.Parse("text(100)"); //specifying a length is unnecessary but don't throws a exception
            } catch (Exception e) { System.Console.Out.WriteLine(e.Message); }

            try
            {
                temp = CSQLDataType.Parse("test"); //throws Exception -> correct, because test isn't an allowed DataType
            }  catch (Exception e) { System.Console.Out.WriteLine(e.Message); }

            try
            {
                temp = CSQLDataType.Parse("decimal(8,2)x"); //throws Exception -> correct, because syntax isn't correct
            }
            catch (Exception e) { System.Console.Out.WriteLine(e.Message); }

            CAbstractCompareResult result = CAlgorithm_DataType.Compare(CSQLDataType.Parse("int"), CSQLDataType.Parse("decimal(8)"));
            result = CAlgorithm_DataType.Compare(CSQLDataType.Parse("text"), CSQLDataType.Parse("varchar(8)"));
            result = CAlgorithm_DataType.Compare(CSQLDataType.Parse("int"), CSQLDataType.Parse("smallint"));
            result = CAlgorithm_DataType.Compare(CSQLDataType.Parse("int"), CSQLDataType.Parse("datetime"));
            result = CAlgorithm_DataType.Compare(CSQLDataType.Parse("datetime"), CSQLDataType.Parse("datetime"));
        }
    }
}
